module API::V3
  class Advertises < Grape::API
    params do
      requires :mac, type: String, regexp: /\A([a-fA-F0-9]{2}:){5}[a-fA-F0-9]{2}\z/
    end
    resource :advertises do
      get do                                                                                                      
        terminal = Terminal.find_by_mac(params[:mac])
        if terminal && tg = terminal.terminal_group
          advertise_group = tg.current_advertise_rule.advertise_group
        end                                                                                                                                               
        present advertise_group.advertises.collect(&:cover_url) if advertise_group
      end
    end
  end               
end